home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
emulation
/
c64gfx
/
src
/
fflitoppm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-14
|
11KB
|
314 lines
/************************************************************************\
* C64 Flickering FLI to Portable pixmap converter 14-Jun-92 *
* By Pasi 'Albert' Ojala © 1991-1998 *
* albert@cs.tut.fi albert@cc.tut.fi *
* *
* 26-Sep-92 Changed the palette a bit *
* 05-Sep-94 Totally revised RGB values for colors *
* 17-Sep-94 Changed the file format a bit, load address $3bff/$3aff+'f' *
* 22-Jan-95 Outputting to stdout added *
* *
\************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Y(r,g,b) ((30*r+59*g+11*b)/100)
#define UBYTE unsigned char
char *vers="\0$VER: FFLItoppm 1.1 (30.7.1998)\n";
UBYTE gfxmem[8192];
UBYTE chrmem1[8192], chrmem2[8192];
UBYTE colmem[1024];
UBYTE bgcol1[256], bgcol2[256];
#define COLORS 136
const UBYTE flashcol[COLORS+1][9] = {
/* col0 col1 R G B Y U V flash */
{ 0, 0, 0, 0, 0, 0,128,128, 0},
{ 0, 1, 120,120,120, 120,128,128, 240},
{ 1, 1, 240,240,240, 240,128,128, 0},
{ 0, 2, 120, 0, 0, 36,116,181, 72},
{ 1, 2, 240,120,120, 156,116,181, 168},
{ 2, 2, 240, 0, 0, 72,103,235, 0},
{ 0, 3, 0,120,120, 84,140, 75, 168},
{ 1, 3, 120,240,240, 204,140, 75, 72},
{ 2, 3, 120,120,120, 120,128,128, 96},
{ 3, 3, 0,240,240, 168,153, 21, 0},
{ 0, 4, 120, 0,120, 49,153,173, 98},
{ 1, 4, 240,120,240, 169,153,173, 142},
{ 2, 4, 240, 0,120, 85,140,227, 26},
{ 3, 4, 120,120,240, 133,166,120, 70},
{ 4, 4, 240, 0,240, 98,179,219, 0},
{ 0, 5, 0,120, 0, 70,103, 84, 141},
{ 1, 5, 120,240,120, 190,103, 84, 99},
{ 2, 5, 120,120, 0, 106, 90,136, 69},
{ 3, 5, 0,240,120, 154,116, 30, 27},
{ 4, 5, 120,120,120, 120,128,128, 43},
{ 5, 5, 0,240, 0, 141, 78, 38, 0},
{ 0, 6, 0, 0,120, 13,166,120, 26},
{ 1, 6, 120,120,240, 133,166,120, 214},
{ 2, 6, 120, 0,120, 49,153,173, 46},
{ 3, 6, 0,120,240, 97,179, 66, 142},
{ 4, 6, 120, 0,240, 62,192,165, 72},
{ 5, 6, 0,120,120, 84,140, 75, 115},
{ 6, 6, 0, 0,240, 26,205,112, 0},
{ 0, 7, 120,120, 0, 106, 90,136, 213},
{ 1, 7, 240,240,120, 226, 90,136, 27},
{ 2, 7, 240,120, 0, 142, 77,190, 141},
{ 3, 7, 120,240,120, 190,103, 84, 45},
{ 4, 7, 240,120,120, 156,116,181, 115},
{ 5, 7, 120,240, 0, 177, 65, 92, 72},
{ 6, 7, 120,120,120, 120,128,128, 187},
{ 7, 7, 240,240, 0, 213, 52,145, 0},
{ 0, 8, 120, 48, 0, 64,105,163, 128},
{ 1, 8, 240,168,120, 184,105,163, 112},
{ 2, 8, 240, 48, 0, 100, 92,217, 56},
{ 3, 8, 120,168,120, 148,118,111, 40},
{ 4, 8, 240, 48,120, 113,130,209, 30},
{ 5, 8, 120,168, 0, 135, 80,119, 13},
{ 6, 8, 120, 48,120, 77,143,155, 102},
{ 7, 8, 240,168, 0, 171, 67,172, 85},
{ 8, 8, 240, 96, 0, 128, 82,199, 0},
{ 0, 9, 80, 32, 0, 42,113,152, 85},
{ 1, 9, 200,152,120, 162,113,152, 155},
{ 2, 9, 200, 32, 0, 78,100,206, 13},
{ 3, 9, 80,152,120, 126,126, 99, 83},
{ 4, 9, 200, 32,120, 92,138,197, 13},
{ 5, 9, 80,152, 0, 113, 88,107, 56},
{ 6, 9, 80, 32,120, 56,151,143, 59},
{ 7, 9, 200,152, 0, 149, 75,160, 128},
{ 8, 9, 200, 80, 0, 107, 90,187, 43},
{ 9, 9, 160, 64, 0, 85, 98,176, 0},
{ 0, 10, 120, 56, 56, 75,122,156, 150},
{ 1, 10, 240,176,176, 195,122,156, 90},
{ 2, 10, 240, 56, 56, 111,109,210, 78},
{ 3, 10, 120,176,176, 159,134,103, 18},
{ 4, 10, 240, 56,176, 124,146,202, 52},
{ 5, 10, 120,176, 56, 146, 96,112, 9},
{ 6, 10, 120, 56,176, 88,159,148, 124},
{ 7, 10, 240,176, 56, 182, 83,165, 63},
{ 8, 10, 240,104, 56, 139, 99,192, 22},
{ 9, 10, 200, 88, 56, 118,106,180, 65},
{10, 10, 240,112,112, 150,115,185, 0},
{ 0, 11, 40, 40, 40, 40,128,128, 80},
{ 1, 11, 160,160,160, 160,128,128, 160},
{ 2, 11, 160, 40, 40, 76,116,181, 8},
{ 3, 11, 40,160,160, 124,140, 75, 88},
{ 4, 11, 160, 40,160, 89,153,173, 18},
{ 5, 11, 40,160, 40, 110,103, 84, 61},
{ 6, 11, 40, 40,160, 53,166,120, 54},
{ 7, 11, 160,160, 40, 146, 90,136, 133},
{ 8, 11, 160, 88, 40, 104,105,163, 48},
{ 9, 11, 120, 72, 40, 82,113,152, 5},
{10, 11, 160, 96, 96, 115,122,156, 70},
{11, 11, 80, 80, 80, 80,128,128, 0},
{ 0, 12, 64, 64, 64, 64,128,128, 128},
{ 1, 12, 184,184,184, 184,128,128, 112},
{ 2, 12, 184, 64, 64, 100,116,181, 56},
{ 3, 12, 64,184,184, 148,140, 75, 40},
{ 4, 12, 184, 64,184, 113,153,173, 30},
{ 5, 12, 64,184, 64, 134,103, 84, 13},
{ 6, 12, 64, 64,184, 77,166,120, 102},
{ 7, 12, 184,184, 64, 170, 90,136, 85},
{ 8, 12, 184,112, 64, 128,105,163, 0},
{ 9, 12, 144, 96, 64, 106,113,152, 43},
{10, 12, 184,120,120, 139,122,156, 22},
{11, 12, 104,104,104, 104,128,128, 48},
{12, 12, 128,128,128, 128,128,128, 0},
{ 0, 13, 72,120, 72, 100,118,111, 200},
{ 1, 13, 192,240,192, 220,118,111, 40},
{ 2, 13, 192,120, 72, 136,105,163, 128},
{ 3, 13, 72,240,192, 184,130, 57, 32},
{ 4, 13, 192,120,192, 149,143,155, 102},
{ 5, 13, 72,240, 72, 171, 93, 65, 59},
{ 6, 13, 72,120,192, 113,156,102, 174},
{ 7, 13, 192,240, 72, 207, 80,119, 13},
{ 8, 13, 192,168, 72, 164, 95,145, 72},
{ 9, 13, 152,152, 72, 143,103,133, 115},
{10, 13, 192,176,128, 175,112,138, 50},
{11, 13, 112,160,112, 140,118,111, 120},
{12, 13, 136,184,136, 164,118,111, 72},
{13, 13, 144,240,144, 200,108, 93, 0},
{ 0, 14, 72, 72,120, 77,143,125, 154},
{ 1, 14, 192,192,240, 197,143,125, 86},
{ 2, 14, 192, 72,120, 113,130,178, 82},
{ 3, 14, 72,192,240, 161,156, 71, 14},
{ 4, 14, 192, 72,240, 126,169,170, 56},
{ 5, 14, 72,192,120, 148,118, 80, 13},
{ 6, 14, 72, 72,240, 90,182,117, 128},
{ 7, 14, 192,192,120, 184,105,133, 59},
{ 8, 14, 192,120,120, 141,121,160, 26},
{ 9, 14, 152,104,120, 120,128,148, 69},
{10, 14, 192,128,176, 152,136,153, 4},
{11, 14, 112,112,160, 117,143,125, 74},
{12, 14, 136,136,184, 141,143,125, 26},
{13, 14, 144,192,192, 177,133,107, 46},
{14, 14, 144,144,240, 154,159,122, 0},
{ 0, 15, 88, 88, 88, 88,128,128, 176},
{ 1, 15, 208,208,208, 208,128,128, 64},
{ 2, 15, 208, 88, 88, 124,116,181, 104},
{ 3, 15, 88,208,208, 172,140, 75, 8},
{ 4, 15, 208, 88,208, 137,153,173, 78},
{ 5, 15, 88,208, 88, 158,103, 84, 35},
{ 6, 15, 88, 88,208, 101,166,120, 150},
{ 7, 15, 208,208, 88, 194, 90,136, 37},
{ 8, 15, 208,136, 88, 152,105,163, 48},
{ 9, 15, 168,120, 88, 130,113,152, 91},
{10, 15, 208,144,144, 163,122,156, 26},
{11, 15, 128,128,128, 128,128,128, 96},
{12, 15, 152,152,152, 152,128,128, 48},
{13, 15, 160,208,160, 188,118,111, 24},
{14, 15, 160,160,208, 165,143,125, 22},
{15, 15, 176,176,176, 176,128,128, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0} /* One extra for NOT_USED */
};
/* Indices to the starts of each group (col1 changes) */
const UBYTE fixedind[16] = {
0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120
};
void Convert(char *name);
int main(int argc, char *argv[]) {
FILE *handle;
UBYTE temp[10];
int i;
if (argc==2 || argc==3) {
if ((handle = fopen(argv[1],"rb"))) {
fread(temp, 2, 1